/* $Id: brdshmctl.c,v 1.3 2007/03/18 07:52:54 sby Exp $ */

#include "bbs.h"
#include "var.c"
#include "cache.c"

#if 0
static int
bfriends_count(const int bid)
{
  register int bfriends_number = 0, i;
  user_info *uentp = NULL;

  for (i = 0; i < USHM_SIZE; i++) 
  {
    uentp = &utmpshm->uinfo[i];

    if (bid && uentp->brc_id == bid)
    {
      bfriends_number++;
    }
  }

  return bfriends_number;
}
#else

static void
bfriends_count(void)
{
  register int i, bid;

  bzero(brdshm->nusers, sizeof(brdshm->nusers));

  for (i = 0; i < USHM_SIZE; i++) 
  {
    if (utmpshm->uinfo[i].brc_id)
    {
      bid = utmpshm->uinfo[i].brc_id - 1;

      if (bid >= MAXBOARD || bid < 0)
	continue;

      if (brdshm->bcache[bid].brdattr & (BRD_GROUPBOARD | BRD_CLASS))
       	continue;

      if (brdshm->bcache[bid].brdname[0])
       	brdshm->nusers[bid]++;
    }
  }
}
#endif

int
main()
{
#if 0
  register int bid;
#endif

  attach_SHM();

#if 0
  for (bid = 0; bid < MAXBOARD; bid++)
  {
    if (brdshm->bcache[bid].brdname[0])
      brdshm->nusers[bid] = bfriends_count(bid + 1);
  }
#else
  bfriends_count();
#endif
  return 0;
}

